<?php
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('data_setting', false);
my_component_load('spd_jarak_tempuh' );
$task = isset($_GET['task']) ? $_GET['task'] : "";  
$id = isset( $_GET['id'] ) ? $_GET['id']:  0; 
$modulname = "Admin _BN_ Konfigurasi Data _BN_ Transport (STPD)";
 
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	$validatepost = create_jarak_tempuh_validate($id);
 	switch($task){  
		case "edit_page":
			if($validatepost){
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= create_data_jarak_tempuh($id);
				generate_my_web($content, $pagename ,"plain.php");
				exit;
			}else{
				create_jarak_tempuh_submit($id );
				$content = "Updated!!";
				generate_my_web($content, $pagename ,"plain.php"); 
				exit;
			}
		break;
	}
else: 	
	if($task == "edit"){ 
		$pagename = ($id > 0 ) ? "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com='.$_GET['com'].'&task=edit_page&id='.$id , $pagename , 210	);
	}elseif($task == "edit_page"){
		$pagename = $modulname." _BN_ Perubahan Data" ;
		$content = create_data_jarak_tempuh($id);
		generate_my_web($content, $pagename ,"plain.php");
		exit;
	}elseif($task =='delete'){
		 delete_jarak_tempuh($id);
		 my_direct($_SERVER['HTTP_REFERER']);			
	}else{ 
		$pagename = "Transport Tambahan untuk STPD" ;
		load_facebox_script();
		$view =  daftar_jarak_tempuh_spd(); 
		$href = 'index.php?com=spd_jarak_tempuh&task=edit&id=0';
	}
endif;  
$content = spliter_browser( $view , $pagename ,$href);
generate_my_web($content, $modulname);
